 package handling.channel.handler;



import client.MapleCharacter;
import client.MapleClient;
import client.MapleTraitType;
import client.PlayerStats;
import client.inventory.*;
import client.skills.SkillFactory;
import configs.CubeConfig;
import configs.SealedConfig;
import configs.ServerConfig;
import configs.StarForceConfig;
import constants.GameConstants;
import constants.ItemConstants;
import constants.JobConstants;
import handling.world.WorldBroadcastService;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.StructItemOption;
import tools.MaplePacketCreator;
import tools.Randomizer;
import tools.data.input.LittleEndianAccessor;
import tools.packet.InventoryPacket;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;


































 public class ItemScrollHandler {
/*  38 */   public static void handlePacket(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr, boolean cash) { if (chr == null || chr.getMap() == null) {
       return;
     }
/*  41 */     chr.updateTick(slea.readInt());
/*  42 */     short slot = slea.readShort();
/*  43 */     short dst = slea.readShort();
/*  44 */     short ws = 0;
/*  45 */     int number = 0;
/*  46 */     if (slea.available() >= 3L) {
/*  47 */       ws = slea.readShort();
     }
/*  49 */     if (slea.available() >= 5L) {
/*  50 */       number = slea.readInt();
     }



/*  55 */     UseUpgradeScroll(slot, dst, ws, c, chr, 0, cash, number); }
   public static boolean UseUpgradeScroll(short slot, short dst, short ws, MapleClient c, MapleCharacter chr, int vegas, boolean cash, int number) { Equip toScroll;
     Item scroll;
     Equip.ScrollResult scrollSuccess;
/*  59 */     boolean whiteScroll = false;
/*  60 */     boolean legendarySpirit = false;
/*  61 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/*  62 */     chr.setScrolledPosition((short)0);
/*  63 */     if ((ws & 0x2) == 2) {
/*  64 */       whiteScroll = true;
     }

/*  67 */     if (dst < 0) {
/*  68 */       toScroll = (Equip)chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
     } else {
/*  70 */       legendarySpirit = true;
/*  71 */       toScroll = (Equip)chr.getInventory(MapleInventoryType.EQUIP).getItem(dst);
     }
/*  73 */     if (toScroll == null || c.getPlayer().hasBlockedInventory()) {
/*  74 */       return false;
     }
/*  76 */     byte oldLevel = toScroll.getLevel();
/*  77 */     byte oldEnhance = toScroll.getEnhance();
/*  78 */     byte oldState = toScroll.getState(false);
/*  79 */     byte oldAddState = toScroll.getState(true);
/*  80 */     short oldFlag = toScroll.getFlag();
/*  81 */     byte oldSlots = toScroll.getUpgradeSlots();
/*  82 */     long oldLimitBreak = toScroll.getLimitBreak();
/*  83 */     byte oldSealedLevel = toScroll.getSealedLevel();
/*  84 */     int sealedNeedScrollNum = SealedConfig.SEALED_OPEN ? GameConstants.getSealedNeedScrollNum(toScroll.getSealedLevel()) : 1;


/*  87 */     if (cash) {
/*  88 */       scroll = chr.getInventory(MapleInventoryType.CASH).getItem(slot);
     } else {
/*  90 */       scroll = chr.getInventory(MapleInventoryType.USE).getItem(slot);
     }
/*  92 */     if (scroll == null) {
/*  93 */       if (chr.isAdmin()) {
/*  94 */         chr.dropMessage(-9, "砸卷错误: 卷轴道具为空");
       }
/*  96 */       c.announce(InventoryPacket.getInventoryFull());
/*  97 */       return false;
     }
/*  99 */     if (chr.isAdmin()) {
/* 100 */       chr.dropSpouseMessage(10, "砸卷信息: 卷轴ID " + scroll.getItemId() + " 卷轴名字 " + ii.getName(scroll.getItemId()));
     }
/* 102 */     if (!ItemConstants.isSpecialScroll(scroll.getItemId()) && 
/* 103 */       !ItemConstants.isCleanSlate(scroll.getItemId()) && 
/* 104 */       !ItemConstants.isEquipScroll(scroll.getItemId()) && 
/* 105 */       !ItemConstants.isPotentialScroll(scroll.getItemId()) && 
/* 106 */       !ItemConstants.isPotentialAddScroll(scroll.getItemId()) && 
/* 107 */       !ItemConstants.isLimitBreakScroll(scroll.getItemId()) && 
/* 108 */       !ItemConstants.isResetScroll(scroll.getItemId()) && 
/* 109 */       !ItemConstants.isSealedScroll(scroll.getItemId()) && 
/* 110 */       !ItemConstants.isUpgradeItemEx(scroll.getItemId())) {
/* 111 */       int scrollSlots = ItemConstants.isAzwanScroll(scroll.getItemId()) ? ii.getSlots(scroll.getItemId()) : 1;
/* 112 */       if (toScroll.getUpgradeSlots() < scrollSlots) {
/* 113 */         chr.dropMessage(1, "当前装备可升级次数为: " + toScroll.getUpgradeSlots() + " 成功或失败需要减少: " + scrollSlots + " 的升级次数，请检查该装备是否符合升级条件.");
/* 114 */         c.announce(InventoryPacket.getInventoryFull());
/* 115 */         return false;
       }
/* 117 */     } else if (ItemConstants.isEquipScroll(scroll.getItemId())) {
/* 118 */       if (toScroll.getUpgradeSlots() >= 1 || toScroll.getEnhance() >= 100 || vegas > 0 || ii.isCash(toScroll.getItemId())) {
/* 119 */         if (chr.isAdmin()) {
/* 120 */           chr.dropMessage(-9, "砸卷错误: 强化卷轴检测 装备是否有升级次数: " + ((toScroll.getUpgradeSlots() >= 1) ? 1 : 0) + " 装备星级是否大于100星: " + ((toScroll.getEnhance() >= 100) ? 1 : 0) + " - " + ((vegas > 0) ? 1 : 0) + " 装备是是否为点装: " + ii.isCash(toScroll.getItemId()));
         }
/* 122 */         c.announce(InventoryPacket.getInventoryFull());
/* 123 */         return false;
       }

/* 126 */       int i = ii.getForceUpgrade(scroll.getItemId());















     }
/* 143 */     else if (ItemConstants.isPotentialScroll(scroll.getItemId())) {
/* 144 */       boolean isSpecialScrollA = (scroll.getItemId() / 100 == 20497);
/* 145 */       boolean isSpecialEquip = (toScroll.getItemId() / 10000 == 135 || toScroll.getItemId() / 1000 == 1098 || toScroll.getItemId() / 1000 == 1099 || toScroll.getItemId() / 1000 == 1190);
/* 146 */       if ((!isSpecialScrollA && toScroll.getState(false) >= 1) || (isSpecialScrollA && toScroll.getState(false) >= 18) || (toScroll.getLevel() == 0 && toScroll.getUpgradeSlots() == 0 && !isSpecialScrollA && !isSpecialEquip) || vegas > 0 || ii.isCash(toScroll.getItemId())) {
/* 147 */         if (chr.isAdmin()) {
/* 148 */           chr.dropMessage(-9, "砸卷错误: isPotentialScroll " + ((toScroll.getState(false) >= 1) ? 1 : 0) + " " + ((toScroll.getLevel() == 0 && toScroll.getUpgradeSlots() == 0 && !isSpecialScrollA && !isSpecialEquip) ? 1 : 0) + " " + ((vegas > 0) ? 1 : 0) + " " + ii.isCash(toScroll.getItemId()));
         }
/* 150 */         c.announce(InventoryPacket.getInventoryFull());
/* 151 */         return false;
       }
/* 153 */     } else if (ItemConstants.isPotentialAddScroll(scroll.getItemId())) {
/* 154 */       boolean isA级潜能卷轴 = (scroll.getItemId() / 100 == 20497);
/* 155 */       boolean is特殊装备 = (toScroll.getItemId() / 10000 == 135 || toScroll.getItemId() / 1000 == 1098 || toScroll.getItemId() / 1000 == 1099 || toScroll.getItemId() / 1000 == 1190);
/* 156 */       if (vegas > 0 || ii.isCash(toScroll.getItemId()) || (toScroll.getState(true) > 0 && !isA级潜能卷轴 && !is特殊装备)) {
/* 157 */         if (chr.isAdmin()) {
/* 158 */           chr.dropMessage(-9, "砸卷错误: isPotentialAddScroll " + ((toScroll.getState(true) >= 1) ? 1 : 0) + " " + ((toScroll.getLevel() == 0 && toScroll.getUpgradeSlots() == 0 && !isA级潜能卷轴 && !is特殊装备) ? 1 : 0) + " " + ((vegas > 0) ? 1 : 0) + " " + ii.isCash(toScroll.getItemId()));
         }
/* 160 */         c.announce(InventoryPacket.getInventoryFull());
/* 161 */         return false;
       }
/* 163 */     } else if (ItemConstants.isUpgradeItemEx(scroll.getItemId())) {
/* 164 */       if (toScroll.getReqLevel() > ii.getReqEquipLevelMax(scroll.getItemId())) {
/* 165 */         if (chr.isAdmin()) {
/* 166 */           chr.dropMessage(-9, "砸卷错误: 涅槃火焰 装备等级超过限定等级");
         }
/* 168 */         c.announce(InventoryPacket.getInventoryFull());
/* 169 */         return false;
       }
/* 171 */     } else if (ItemConstants.isSpecialScroll(scroll.getItemId())) {

/* 173 */       int maxEnhance = (scroll.getItemId() == 5064003) ? 7 : 12;
/* 174 */       if (ii.isCash(toScroll.getItemId()) || toScroll.getEnhance() >= maxEnhance) {
/* 175 */         if (chr.isAdmin()) {
/* 176 */           chr.dropMessage(-9, "砸卷错误: 特殊卷轴 isCash - " + ii.isCash(toScroll.getItemId()) + " getEnhance - " + ((toScroll.getEnhance() >= maxEnhance) ? 1 : 0) + " 保护星级: " + maxEnhance);
         }
/* 178 */         c.announce(InventoryPacket.getInventoryFull());
/* 179 */         return false;
       }
/* 181 */     } else if (ItemConstants.isLimitBreakScroll(scroll.getItemId())) {
/* 182 */       if (!ItemConstants.isWeapon(toScroll.getItemId()) || ii.getScrollLimitBreak(scroll.getItemId()) + oldLimitBreak > ServerConfig.CHANNEL_PLAYER_LIMITBREAK) {
/* 183 */         c.announce(InventoryPacket.getInventoryFull());
/* 184 */         return false;
       }
/* 186 */     } else if (ItemConstants.isSealedScroll(scroll.getItemId())) {
/* 187 */       if (!GameConstants.canSealedLevelUp(toScroll.getItemId(), toScroll.getSealedLevel(), toScroll.getSealedExp())) {
/* 188 */         chr.dropMessage(-9, "砸卷错误: 封印解除经验不足或已经达到最高级，无法解除封印。");
/* 189 */         c.announce(InventoryPacket.getInventoryFull());
/* 190 */         return false;
       }
/* 192 */       if (sealedNeedScrollNum > scroll.getQuantity()) {
/* 193 */         chr.dropMessage("砸卷错误: 本次解封需要 " + sealedNeedScrollNum + " 张解封卷轴");
/* 194 */         c.announce(InventoryPacket.getInventoryFull());
/* 195 */         return false;
       }
/* 197 */       if (toScroll.getUpgradeSlots() >= 50) {
/* 198 */         chr.dropMessage("砸卷错误: 您的可升级次数多余50次,无法使用解封卷轴");
       }
     }
/* 201 */     if (!ItemConstants.canScroll(toScroll.getItemId()) && !ItemConstants.isChaosScroll(toScroll.getItemId())) {
/* 202 */       if (chr.isAdmin()) {
/* 203 */         chr.dropMessage(-9, "砸卷错误: 卷轴是否能对装备进行砸卷 " + (!ItemConstants.canScroll(toScroll.getItemId()) ? 1 : 0) + " 是否混沌卷轴 " + (!ItemConstants.isChaosScroll(toScroll.getItemId()) ? 1 : 0));
       }
/* 205 */       c.announce(InventoryPacket.getInventoryFull());
/* 206 */       return false;
     }
/* 208 */     if ((ItemConstants.isCleanSlate(scroll.getItemId()) || ItemConstants.isTablet(scroll.getItemId()) || ItemConstants.isGeneralScroll(scroll.getItemId()) || ItemConstants.isChaosScroll(scroll.getItemId())) && (vegas > 0 || ii.isCash(toScroll.getItemId()))) {
/* 209 */       if (chr.isAdmin()) {
/* 210 */         chr.dropMessage(-9, "砸卷错误: 卷轴是否白衣卷轴 " + ItemConstants.isCleanSlate(scroll.getItemId()) + " isTablet " + ItemConstants.isTablet(scroll.getItemId()));
       }
/* 212 */       c.announce(InventoryPacket.getInventoryFull());
/* 213 */       return false;
     }
/* 215 */     if (ItemConstants.isTablet(scroll.getItemId()) && !ItemConstants.is武器攻击力卷轴(scroll.getItemId()) && toScroll.getDurability() < 0) {
/* 216 */       if (chr.isAdmin()) {
/* 217 */         chr.dropMessage(-9, "砸卷错误: isTablet " + ItemConstants.isTablet(scroll.getItemId()) + " getDurability " + ((toScroll.getDurability() < 0) ? 1 : 0));
       }
/* 219 */       c.announce(InventoryPacket.getInventoryFull());
/* 220 */       return false;
/* 221 */     }  if (!ItemConstants.isTablet(scroll.getItemId()) && !ItemConstants.isPotentialScroll(scroll.getItemId()) && !ItemConstants.isEquipScroll(scroll.getItemId()) && !ItemConstants.isCleanSlate(scroll.getItemId()) && !ItemConstants.isSpecialScroll(scroll.getItemId()) && !ItemConstants.isPotentialAddScroll(scroll.getItemId()) && !ItemConstants.isChaosScroll(scroll.getItemId()) && toScroll.getDurability() >= 0 && !ItemConstants.is随机攻击卷轴(scroll.getItemId())) {
/* 222 */       if (chr.isAdmin()) {
/* 223 */         chr.dropMessage(-9, "砸卷错误: !isTablet ----- 1");
       }
/* 225 */       c.announce(InventoryPacket.getInventoryFull());
/* 226 */       return false;
/* 227 */     }  if (scroll.getItemId() == 2049405 && !ItemConstants.is真觉醒冒险之心(toScroll.getItemId())) {
/* 228 */       chr.dropMessage(1, "该卷轴只能对真·觉醒冒险之心使用。");
/* 229 */       c.announce(InventoryPacket.getInventoryFull());
/* 230 */       return false;
     }
/* 232 */     Item wscroll = null;

/* 234 */     Map<Integer, Integer> scrollReqs = ii.getScrollReqs(scroll.getItemId());
/* 235 */     if (scrollReqs != null && scrollReqs.size() > 0 && !scrollReqs.containsValue(Integer.valueOf(toScroll.getItemId()))) {
/* 236 */       if (chr.isAdmin()) {
/* 237 */         chr.dropMessage(-9, "砸卷错误: 特定卷轴只能对指定的卷轴进行砸卷.");
       }
/* 239 */       c.announce(InventoryPacket.getInventoryFull());
/* 240 */       return false;
     }
/* 242 */     if (whiteScroll) {
/* 243 */       wscroll = chr.getInventory(MapleInventoryType.USE).findById(2340000);
/* 244 */       if (wscroll == null) {
/* 245 */         if (chr.isAdmin()) {
/* 246 */           chr.dropMessage(-9, "砸卷错误: 使用祝福卷轴 但祝福卷轴信息为空.");
         }
/* 248 */         c.announce(InventoryPacket.getInventoryFull());
/* 249 */         whiteScroll = false;
       }
     }
/* 252 */     if (ItemConstants.isTablet(scroll.getItemId()) || ItemConstants.isGeneralScroll(scroll.getItemId())) {
/* 253 */       switch (scroll.getItemId() % 1000 / 100) {
         case 0:
/* 255 */           if (ItemConstants.isTwoHanded(toScroll.getItemId()) || !ItemConstants.isWeapon(toScroll.getItemId())) {
/* 256 */             if (chr.isAdmin()) {
/* 257 */               chr.dropMessage(-9, "砸卷错误: 最后检测 --- 0");
             }
/* 259 */             c.announce(InventoryPacket.getInventoryFull());
/* 260 */             return false;
           }
           break;
         case 1:
/* 264 */           if (!ItemConstants.isTwoHanded(toScroll.getItemId()) || !ItemConstants.isWeapon(toScroll.getItemId())) {
/* 265 */             if (chr.isAdmin()) {
/* 266 */               chr.dropMessage(-9, "砸卷错误: 最后检测 --- 1");
             }
/* 268 */             c.announce(InventoryPacket.getInventoryFull());
/* 269 */             return false;
           }
           break;
         case 2:
/* 273 */           if (ItemConstants.isAccessory(toScroll.getItemId()) || ItemConstants.isWeapon(toScroll.getItemId())) {
/* 274 */             if (chr.isAdmin()) {
/* 275 */               chr.dropMessage(-9, "砸卷错误: 最后检测 --- 2");
             }
/* 277 */             c.announce(InventoryPacket.getInventoryFull());
/* 278 */             return false;
           }
           break;
         case 3:
/* 282 */           if (!ItemConstants.isAccessory(toScroll.getItemId()) || ItemConstants.isWeapon(toScroll.getItemId())) {
/* 283 */             if (chr.isAdmin()) {
/* 284 */               chr.dropMessage(-9, "砸卷错误: 最后检测 --- 3");
             }
/* 286 */             c.announce(InventoryPacket.getInventoryFull());
/* 287 */             return false;
           }
           break;
       }
/* 291 */     } else if (!ItemConstants.isAccessoryScroll(scroll.getItemId()) && 
/* 292 */       !ItemConstants.isChaosScroll(scroll.getItemId()) && 
/* 293 */       !ItemConstants.isCleanSlate(scroll.getItemId()) && 
/* 294 */       !ItemConstants.isEquipScroll(scroll.getItemId()) && 
/* 295 */       !ItemConstants.isPotentialScroll(scroll.getItemId()) && 
/* 296 */       !ItemConstants.isPotentialAddScroll(scroll.getItemId()) && 
/* 297 */       !ItemConstants.isSpecialScroll(scroll.getItemId()) && 
/* 298 */       !ItemConstants.isLimitBreakScroll(scroll.getItemId()) && 
/* 299 */       !ItemConstants.isResetScroll(scroll.getItemId()) && 
/* 300 */       !ItemConstants.is随机攻击卷轴(scroll.getItemId()) && 
/* 301 */       !ItemConstants.isSealedScroll(scroll.getItemId()) && 
/* 302 */       !ItemConstants.isUpgradeItemEx(scroll.getItemId()) && 
/* 303 */       !ii.canScroll(scroll.getItemId(), toScroll.getItemId())) {
/* 304 */       if (chr.isAdmin()) {
/* 305 */         chr.dropMessage(-9, "砸卷错误: 砸卷的卷轴无法对装备进行砸卷");
       }
/* 307 */       c.announce(InventoryPacket.getInventoryFull());
/* 308 */       return false;
     }

/* 311 */     if (ItemConstants.isAccessoryScroll(scroll.getItemId()) && !ItemConstants.isAccessory(toScroll.getItemId())) {
/* 312 */       if (chr.isAdmin()) {
/* 313 */         chr.dropMessage(-9, "砸卷错误: 卷轴为配置卷轴 但砸卷的装备不是配饰");
       }
/* 315 */       c.announce(InventoryPacket.getInventoryFull());
/* 316 */       return false;
     }
/* 318 */     if (scroll.getQuantity() <= 0) {
/* 319 */       chr.dropSpouseMessage(11, "砸卷错误，背包卷轴[" + ii.getName(scroll.getItemId()) + "]数量为 0 .");
/* 320 */       c.announce(InventoryPacket.getInventoryFull());
/* 321 */       return false;
     }
/* 323 */     if (legendarySpirit && vegas == 0 && 
/* 324 */       chr.getSkillLevel(SkillFactory.getSkill(PlayerStats.getSkillByJob(1003, chr.getJob()))) <= 0 && ServerConfig.LOGIN_MAPLE_VERSION < 110) {
/* 325 */       if (chr.isAdmin()) {
/* 326 */         chr.dropMessage(-9, "砸卷错误: 检测是否技能砸卷 角色没有拥有技能");
       }
/* 328 */       c.announce(InventoryPacket.getInventoryFull());
/* 329 */       return false;
     }

/* 332 */     Equip scrolled = (Equip)ii.scrollEquipWithId((Item)toScroll, scroll, whiteScroll, chr, vegas, number);

/* 334 */     if (scrolled == null) {
/* 335 */       if (ItemFlag.装备防爆.check(oldFlag)) {
/* 336 */         scrolled = toScroll;
/* 337 */         scrollSuccess = Equip.ScrollResult.失败;
/* 338 */         scrolled.removeFlag((short)ItemFlag.装备防爆.getValue());
/* 339 */         chr.dropSpouseMessage(11, "由于卷轴的效果，物品没有损坏。");
/* 340 */       } else if (ItemConstants.isAdvancedEquipScroll(scroll.getItemId())) {
/* 341 */         scrollSuccess = Equip.ScrollResult.失败;
       } else {
/* 343 */         scrollSuccess = Equip.ScrollResult.消失;
       }
     } else {
/* 346 */       if ((scroll.getItemId() / 100 == 20497 && scrolled.getState(false) == 1) || scrolled.getLevel() > oldLevel || scrolled.getEnhance() > oldEnhance || scrolled.getState(false) > oldState || scrolled.getFlag() > oldFlag || scrolled.getState(true) > oldAddState || scrolled.getLimitBreak() > oldLimitBreak || scrolled.getSealedLevel() > oldSealedLevel) {
/* 347 */         scrollSuccess = Equip.ScrollResult.成功;
/* 348 */       } else if (ItemConstants.isCleanSlate(scroll.getItemId()) && scrolled.getUpgradeSlots() > oldSlots) {
/* 349 */         scrollSuccess = Equip.ScrollResult.成功;
/* 350 */       } else if (ItemConstants.isResetScroll(scroll.getItemId()) && scrolled != toScroll) {
/* 351 */         scrollSuccess = Equip.ScrollResult.成功;
/* 352 */       } else if (ItemConstants.isUpgradeItemEx(scroll.getItemId())) {
/* 353 */         scrollSuccess = Equip.ScrollResult.成功;
       } else {
/* 355 */         scrollSuccess = Equip.ScrollResult.失败;
       }

/* 358 */       if (ItemFlag.装备防爆.check(oldFlag) && !ItemConstants.isCleanSlate(scroll.getItemId()) && !ItemConstants.isSpecialScroll(scroll.getItemId())) {
/* 359 */         scrolled.removeFlag((short)ItemFlag.装备防爆.getValue());
       }

/* 362 */       if (chr.isIntern()) {
/* 363 */         scrolled.addFlag((short)ItemFlag.CRAFTED.getValue());
/* 364 */         scrolled.setOwner(chr.getName());
       }
     }

/* 368 */     if (ItemFlag.卷轴防护.check(oldFlag)) {
/* 369 */       if (scrolled != null) {
/* 370 */         scrolled.removeFlag((short)ItemFlag.卷轴防护.getValue());
       }
/* 372 */       if (scrollSuccess == Equip.ScrollResult.成功) {
/* 373 */         chr.getInventory(ItemConstants.getInventoryType(scroll.getItemId())).removeItem(scroll.getPosition(), (number > 0) ? (short)number : 1, false);
       } else {
/* 375 */         chr.dropSpouseMessage(11, "由于卷轴的效果，卷轴" + ii.getName(scroll.getItemId()) + "没有消失。");
       }
     } else {
/* 378 */       chr.getInventory(ItemConstants.getInventoryType(scroll.getItemId())).removeItem(scroll.getPosition(), (number > 0) ? (short)number : 1, false);
     }
/* 380 */     if (whiteScroll) {
/* 381 */       MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, wscroll.getPosition(), (short)1, false, false);
/* 382 */     } else if (scrollSuccess == Equip.ScrollResult.失败 && scrolled.getUpgradeSlots() < oldSlots && chr.getInventory(MapleInventoryType.CASH).findById(5640000) != null) {
/* 383 */       chr.setScrolledPosition(scrolled.getPosition());
/* 384 */       if (vegas == 0) {
/* 385 */         c.announce(MaplePacketCreator.pamSongUI());
       }
     }
/* 388 */     List<ModifyInventory> mods = new ArrayList<>();
/* 389 */     mods.add(new ModifyInventory((scroll.getQuantity() > 0) ? 1 : 3, scroll));
/* 390 */     if (scrollSuccess == Equip.ScrollResult.消失) {
/* 391 */       mods.add(new ModifyInventory(3, (Item)toScroll));
/* 392 */       if (dst < 0) {
/* 393 */         chr.getInventory(MapleInventoryType.EQUIPPED).removeItem(toScroll.getPosition());
       } else {
/* 395 */         chr.getInventory(MapleInventoryType.EQUIP).removeItem(toScroll.getPosition());
       }
/* 397 */     } else if (vegas == 0) {
/* 398 */       mods.add(new ModifyInventory(3, (Item)scrolled));
/* 399 */       mods.add(new ModifyInventory(0, (Item)scrolled));
     }
/* 401 */     c.announce(InventoryPacket.modifyInventory(true, mods, chr));
/* 402 */     chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), scrollSuccess, legendarySpirit, whiteScroll, scroll.getItemId(), toScroll.getItemId()), (vegas == 0));
/* 403 */     if (dst < 0 && (scrollSuccess == Equip.ScrollResult.成功 || scrollSuccess == Equip.ScrollResult.消失) && vegas == 0) {
/* 404 */       chr.equipChanged();
     }
/* 406 */     chr.finishActivity(120102);
/* 407 */     if (scrolled != null) {
/* 408 */       chr.forceReAddItem_NoUpdate((Item)scrolled, (scrolled.getPosition() >= 0) ? MapleInventoryType.EQUIP : MapleInventoryType.EQUIPPED);
/* 409 */       if (scrolled.getEnhance() > oldEnhance && scrolled.getEnhance() > 5) {
/* 410 */         chr.getClient().getChannelServer().startMapEffect(chr.getName() + "成功将" + ii.getName(scrolled.getItemId()) + "强化至 " + scrolled.getEnhance() + "星！", 5120037);
       }
/* 412 */       if (scrolled.getSealedLevel() > oldSealedLevel) {
/* 413 */         WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.itemMegaphone("[全服公告] : " + chr.getName() + "成功将装备解封至 " + scrolled.getSealedLevel() + "级，大家恭喜Ta！", false, c.getChannel(), (Item)scrolled));
/* 414 */         chr.dropMessage("[漩涡解封] \r\n\r\n下次解封需要 " + GameConstants.getSealedNeedScrollNum(scrolled.getSealedLevel()) + " 张解封卷轴");
       }
     }
/* 417 */     return (scrollSuccess == Equip.ScrollResult.成功); } public static void UseEquipEnchanting(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) { short s1; boolean bl3; short src; int slot, n2; short s3; boolean bl5; short dec; Equip equip, toEnhance; short s4; NirvanaFlame nirvanaFlame; Item toScroll; Equip nEquip;
     Item e3;
     ArrayList<EnchantScrollEntry> scrollList;
     EnchantScrollEntry enchantScrollEntry;
/* 421 */     int mode = slea.readByte();
/* 422 */     switch (mode) {
       case 0:
/* 424 */         chr.updateTick(slea.readInt());
/* 425 */         s1 = slea.readShort();
/* 426 */         s3 = slea.readShort();
/* 427 */         s4 = slea.readShort();
/* 428 */         toScroll = chr.getInventory((s1 < 0) ? MapleInventoryType.EQUIPPED : MapleInventoryType.EQUIP).getItem(s1);
/* 429 */         if (toScroll == null) {
/* 430 */           chr.send(InventoryPacket.enchantingOperation(104, 0, null, null, null));
/* 431 */           c.sendEnableActions();
           return;
         }
/* 434 */         nEquip = (Equip)toScroll;
/* 435 */         e3 = toScroll.copy();
/* 436 */         scrollList = EnchantHandler.Companion.getScrollList(nEquip);
/* 437 */         if (scrollList.isEmpty() || scrollList.size() < s3 - 1 || nEquip.getUpgradeSlots() < 1 || !c.getPlayer().haveItem(4001832, ((EnchantScrollEntry)scrollList.get(s3)).getNeed())) {
/* 438 */           c.sendEnableActions();
/* 439 */           if (c.getPlayer().isAdmin()) {
/* 440 */             c.getPlayer().dropMessage(-9, "[咒语痕迹] 检测：找不到卷轴：" + scrollList.isEmpty() + " 收到的卷轴不在范围：" + ((scrollList.size() < s3 - 1) ? 1 : 0) + " 沒有剩余次数：" + ((nEquip.getUpgradeSlots() < 1) ? 1 : 0) + " 痕迹不足：" + (!c.getPlayer().haveItem(4001832, ((EnchantScrollEntry)scrollList.get(s3)).getNeed()) ? 1 : 0));
           }
/* 442 */           if (nEquip.getUpgradeSlots() < 1) {
/* 443 */             c.getPlayer().dropMessage(-1, "当前道具已经不能在进行强化！");
           }
/* 445 */           chr.send(InventoryPacket.enchantingOperation(104, 0, null, null, null));
           return;
         }
/* 448 */         enchantScrollEntry = scrollList.get(s3);
/* 449 */         if (Randomizer.isSuccess(enchantScrollEntry.getSucess())) {
/* 450 */           s4 = 1;
         }
/* 452 */         if (c.getPlayer().isAdmin()) {
/* 453 */           c.getPlayer().dropMessage(-9, "[咒语痕迹] 强化道具：" + toScroll + " 选中卷轴:" + enchantScrollEntry.getName() + " 消耗痕迹：" + (enchantScrollEntry.getNeed() * getNeedRate(nEquip.getReqLevel())) + " 成功率：" + enchantScrollEntry.getSucess() + "%  强化結果：" + ((s4 == 1) ? 1 : 0));
         }
/* 455 */         enchantScrollEquip(enchantScrollEntry, nEquip, s4, c, false);
/* 456 */         chr.forceUpdateItem((Item)nEquip, true);
/* 457 */         chr.send(InventoryPacket.enchantingOperation(100, s4, e3, toScroll, null, enchantScrollEntry.getName()));
/* 458 */         chr.send(InventoryPacket.enchantingOperation(50, 0, null, (Item)nEquip, EnchantHandler.Companion.getScrollList(nEquip)));
         break;


       case 1:
/* 463 */         chr.updateTick(slea.readInt());
/* 464 */         slea.readShort();
/* 465 */         bl3 = (slea.readByte() == 1);
/* 466 */         if (bl3) {
/* 467 */           slea.readInt();
         }
/* 469 */         slea.readInt();
/* 470 */         slea.readInt();
/* 471 */         bl5 = (slea.readByte() == 1);
/* 472 */         if (enchantEnhance(chr, (short)chr.getEnchant(), bl3, bl5))
/* 473 */           break;  chr.send(InventoryPacket.enchantingOperation(104, 0, null, null, null));
         break;

       case 2:
/* 477 */         chr.updateTick(slea.readInt());
/* 478 */         src = slea.readShort();
/* 479 */         dec = slea.readShort();
/* 480 */         inheritEquip(chr, src, dec);
/* 481 */         chr.sendEnableActions();
         break;

       case 50:
/* 485 */         slot = slea.readInt();
/* 486 */         equip = (Equip)chr.getInventory((slot < 0) ? MapleInventoryType.EQUIPPED : MapleInventoryType.EQUIP).getItem((short)slot);
/* 487 */         chr.send(InventoryPacket.enchantingOperation(mode, 0, null, (Item)equip, EnchantHandler.Companion.getScrollList(equip)));
         break;





       case 52:
/* 495 */         n2 = slea.readInt();
/* 496 */         chr.setEnchant(n2);
/* 497 */         toEnhance = (n2 < 0) ? (Equip)chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short)n2) : (Equip)chr.getInventory(MapleInventoryType.EQUIP).getItem((short)n2);
/* 498 */         nirvanaFlame = new NirvanaFlame(toEnhance.getNirvanaFlame());
/* 499 */         toEnhance.getNirvanaFlame().reset();
/* 500 */         chr.send(InventoryPacket.enchantingOperation(mode, 0, (Item)toEnhance, null, null));
/* 501 */         toEnhance.setNirvanaFlame(nirvanaFlame);
         break;











       case 51:
       case 53:
/* 516 */         c.announce(InventoryPacket.enchantingOperation(mode, 0, null, null, null));
         break;
     }  }



   public static void inheritEquip(MapleCharacter chr, short src, short dec) {
/* 523 */     ArrayList<ModifyInventory> mods = new ArrayList<>();
/* 524 */     Equip srcEquip = (Equip)chr.getInventory((src < 0) ? MapleInventoryType.EQUIPPED : MapleInventoryType.EQUIP).getItem(src);
/* 525 */     Equip decEquip = (Equip)chr.getInventory(MapleInventoryType.EQUIP).getItem(dec);
/* 526 */     srcEquip.inherit(decEquip, srcEquip);
/* 527 */     if (EnhanceResultType.EQUIP_MARK.check(decEquip.getEnhanctBuff())) {
/* 528 */       srcEquip.setEnhanctBuff((short)(decEquip.getEnhanctBuff() - EnhanceResultType.EQUIP_MARK.getValue()));
/* 529 */       srcEquip.addFlag((short)ItemFlag.不可交易.getValue());
/* 530 */       srcEquip.setOwner(chr.getName());
/* 531 */       mods.add(new ModifyInventory(3, (Item)srcEquip));
/* 532 */       mods.add(new ModifyInventory(0, (Item)srcEquip));
/* 533 */       mods.add(new ModifyInventory(3, (Item)decEquip));
/* 534 */       chr.getInventory(MapleInventoryType.EQUIP).removeItem(decEquip.getPosition());
/* 535 */       chr.send(InventoryPacket.enchantingOperation(103, 0, (Item)decEquip, (Item)srcEquip, null));
/* 536 */       chr.send(InventoryPacket.modifyInventory(true, mods, chr));
/* 537 */       chr.equipChanged();
     } else {
/* 539 */       chr.send(InventoryPacket.enchantingOperation(104, 0, null, null, null));
     }
   }

   public static boolean enchantEnhance(MapleCharacter chr, short slot, boolean bl2, boolean bl3) {
/* 544 */     chr.setScrolledPosition((short)0);
/* 545 */     Equip item = (slot < 0) ? (Equip)chr.getInventory(MapleInventoryType.EQUIPPED).getItem(slot) : (Equip)chr.getInventory(MapleInventoryType.EQUIP).getItem(slot);
/* 546 */     if (item == null || chr.hasBlockedInventory()) {
/* 547 */       return false;
     }
/* 549 */     if (item.getEnhance() >= ItemConstants.getMaxEnhance(item.getItemId())) {
/* 550 */       chr.send(InventoryPacket.enchantingOperation(33, 0, null, null, null));
/* 551 */       return false;
     }
/* 553 */     int n2 = 2 * (item.getEnhance() * item.getEnhance() + 2) * (bl3 ? 2 : 1);
/* 554 */     if (chr.getItemQuantity(4001839) < n2) {
/* 555 */       return false;
     }
/* 557 */     chr.removeItem(4001839, n2);
/* 558 */     byte by2 = item.getEnhance();
/* 559 */     Item toEnhance = item.copy();
/* 560 */     int n3 = bl2 ? 8 : 0;
/* 561 */     NirvanaFlame nirvanaFlame = new NirvanaFlame(item.getNirvanaFlame());
/* 562 */     Equip nEquip = toStarForce((Item)item, chr, n3, bl3);
/* 563 */     nEquip.setNirvanaFlame(nirvanaFlame);
/* 564 */     ArrayList<ModifyInventory> arrayList = new ArrayList<>();
/* 565 */     if (EnhanceResultType.EQUIP_MARK.check(nEquip.getEnhanctBuff())) {
/* 566 */       chr.send(InventoryPacket.enchantingOperation(101, 2, toEnhance, (Item)nEquip, null));
/* 567 */       if (slot < 0) {
/* 568 */         MapleInventoryManipulator.unequip(chr.getClient(), slot, chr.getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
       }
/* 570 */       arrayList.add(new ModifyInventory(3, (Item)nEquip));
/* 571 */       arrayList.add(new ModifyInventory(0, (Item)nEquip));
/* 572 */     } else if (nEquip.getEnhance() > by2) {
/* 573 */       if (slot < 0) {
/* 574 */         chr.equipChanged();
       }
/* 576 */       nEquip.setBonus(0);
/* 577 */       arrayList.add(new ModifyInventory(3, (Item)nEquip));
/* 578 */       arrayList.add(new ModifyInventory(0, (Item)nEquip));
/* 579 */       chr.send(InventoryPacket.enchantingOperation(101, 1, toEnhance, (Item)nEquip, null));
/* 580 */     } else if (nEquip.getEnhance() < by2) {
/* 581 */       nEquip.setBonus(nEquip.getBonus() + 1);
/* 582 */       arrayList.add(new ModifyInventory(3, (Item)nEquip));
/* 583 */       arrayList.add(new ModifyInventory(0, (Item)nEquip));
/* 584 */       chr.send(InventoryPacket.enchantingOperation(101, 0, toEnhance, (Item)nEquip, null));
     } else {
/* 586 */       nEquip.setBonus(nEquip.getBonus() + 1);
/* 587 */       chr.send(InventoryPacket.enchantingOperation(101, 3, toEnhance, toEnhance, null));
     }
/* 589 */     if (slot < 0) {
/* 590 */       chr.equipChanged();
     }
/* 592 */     chr.forceUpdateItem((Item)nEquip, true);
/* 593 */     chr.send(InventoryPacket.modifyInventory(true, arrayList, chr));
/* 594 */     return true;
   }

   public static Equip toStarForce(Item item, MapleCharacter chr, int n2, boolean bl2) {
/* 598 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 599 */     Equip nEquip = (Equip)item;
/* 600 */     byte by2 = nEquip.getEnhance();
/* 601 */     boolean bl3 = ii.isSuperiorEquip(nEquip.getItemId());
/* 602 */     boolean bl4 = nEquip.getStartCurse();
/* 603 */     boolean bl5 = false;
/* 604 */     int n3 = nEquip.getNeedStar() * 10;
/* 605 */     int n4 = chr.getTrait(MapleTraitType.craft).getLevel() / 10;
/* 606 */     int rate = n3 + n3 * n4 / 10 + n2 * 10;
/* 607 */     int n6 = (bl4 && (!bl2 || bl3)) ? ((1000 - n3) * (bl3 ? (by2 - 4) : (by2 - 14)) / 18) : 0;
/* 608 */     int n7 = nEquip.getStartDown() ? (1000 - n3) : 0;
/* 609 */     rate = chr.isAdmin() ? 1000 : rate;

/* 611 */     if (chr.isAdmin()) {
/* 612 */       chr.dropSpouseMessage(11, "[星之力强化] 默认几率: " + (n3 / 10) + "% 倾向加成: " + n4 + "% 最终几率: " + (rate / 10) + "% 失败下降几率: " + (n7 / 10) + "% 失败消失几率: " + (n6 / 10) + "%");
     }
/* 614 */     if (by2 >= ItemConstants.getMaxEnhance(nEquip.getItemId())) {
/* 615 */       return nEquip;
     }
/* 617 */     nEquip.getNirvanaFlame().reset();
/* 618 */     int rand = Randomizer.nextInt(1000);
/* 619 */     int curseReduceCount = StarForceConfig.CURSE_REDUCE_COUNT;
/* 620 */     curseReduceCount = (curseReduceCount >= 0) ? curseReduceCount : nEquip.getEnhance();
/* 621 */     if (rate < rand && !nEquip.getBonusTime()) {
/* 622 */       if (rate < rand && rand < rate + n6) {
/* 623 */         for (int i2 = 0; i2 < curseReduceCount; i2++) {
/* 624 */           EnchantHandler.Companion.toEnchantScrollHandler((Item)nEquip, true);
         }
/* 626 */         nEquip.setEnhanctBuff((short)(nEquip.getEnhanctBuff() | EnhanceResultType.EQUIP_MARK.getValue()));
/* 627 */         return nEquip;
       }
/* 629 */       if (rate + n6 < rand && rand < n3 + n6 + n7 && by2 > 5 && by2 != 10 && by2 != 15 && by2 != 20) {
/* 630 */         bl5 = true;
       } else {
/* 632 */         return nEquip;
       }
     }
/* 635 */     EnchantHandler.Companion.toEnchantScrollHandler((Item)nEquip, bl5);
/* 636 */     return nEquip;
   }

   public static void enchantScrollEquip(EnchantScrollEntry scrollEntry, Equip equip, int mode, MapleClient c, boolean update) {
/* 640 */     int mask = scrollEntry.getMask();
/* 641 */     NirvanaFlame nirvanaFlame = new NirvanaFlame(equip.getNirvanaFlame());
/* 642 */     equip.getNirvanaFlame().reset();
/* 643 */     if (scrollEntry.getViewType() < 4) {
/* 644 */       if (mode == 1) {
/* 645 */         for (int value : scrollEntry.getValues()) {
/* 646 */           if (EnchantScrollFlag.物攻.check(mask)) {
/* 647 */             mask -= EnchantScrollFlag.物攻.getValue();
/* 648 */             equip.setWatk((short)(equip.getWatk() + value));

           }
/* 651 */           else if (EnchantScrollFlag.魔攻.check(mask)) {
/* 652 */             mask -= EnchantScrollFlag.魔攻.getValue();
/* 653 */             equip.setMatk((short)(equip.getMatk() + value));

           }
/* 656 */           else if (EnchantScrollFlag.力量.check(mask)) {
/* 657 */             mask -= EnchantScrollFlag.力量.getValue();
/* 658 */             equip.setStr((short)(equip.getStr() + value));

           }
/* 661 */           else if (EnchantScrollFlag.敏捷.check(mask)) {
/* 662 */             mask -= EnchantScrollFlag.敏捷.getValue();
/* 663 */             equip.setDex((short)(equip.getDex() + value));

           }
/* 666 */           else if (EnchantScrollFlag.智力.check(mask)) {
/* 667 */             mask -= EnchantScrollFlag.智力.getValue();
/* 668 */             equip.setInt((short)(equip.getInt() + value));

           }
/* 671 */           else if (EnchantScrollFlag.运气.check(mask)) {
/* 672 */             mask -= EnchantScrollFlag.运气.getValue();
/* 673 */             equip.setLuk((short)(equip.getLuk() + value));

           }
/* 676 */           else if (EnchantScrollFlag.Hp.check(mask)) {
/* 677 */             mask -= EnchantScrollFlag.Hp.getValue();
/* 678 */             equip.setHp((short)(equip.getHp() + value));
           }
         }
/* 681 */         equip.setLevel((byte)(equip.getLevel() + 1));
       }
/* 683 */       equip.setUpgradeSlots((byte)(equip.getUpgradeSlots() - 1));
     }
/* 685 */     equip.setNirvanaFlame(nirvanaFlame);
/* 686 */     if (!update) {
/* 687 */       MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(4001832), 4001832, scrollEntry.getNeed() * getNeedRate(equip.getReqLevel()), true, false);
/* 688 */       c.getPlayer().forceReAddItem((Item)equip, (equip.getPosition() >= 0) ? MapleInventoryType.EQUIP : MapleInventoryType.EQUIPPED);
     }
   }

   public static int getNeedRate(int reqLevel) {
/* 693 */     switch (reqLevel / 20) {
       case 0:
       case 1:
/* 696 */         return 1;

       case 2:
       case 3:
/* 700 */         return 2;

       case 4:
/* 703 */         return 5;

       case 5:
/* 706 */         return 6;

       case 6:
/* 709 */         return 7;

       case 7:
/* 712 */         return 8;
     }

/* 715 */     return 5;
   }

   public static void ChangeWeaponPotential(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/* 719 */     slea.skip(4);
/* 720 */     int mode = slea.readByte();
/* 721 */     if (mode == 1) {
/* 722 */       Item lazuliItem = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short)-11);
/* 723 */       Item lapisItem = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short)-10);
/* 724 */       int level = (int)(Math.floor((chr.getLevel() / 10)) * 10.0D + 10.0D);
/* 725 */       c.announce(InventoryPacket.getZeroWeaponInfo(lazuliItem.getItemId() % 10, level, Math.min(1562007, lazuliItem.getItemId() + 1), Math.min(1572007, lapisItem.getItemId() + 1)));
/* 726 */       c.announce(InventoryPacket.getZeroWeaponChangePotential(100000, 600));
     }
   }

   public static void ChangeWeaponPotential_WP(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/* 731 */     if (chr.getWeaponPoint() >= 600 && chr.getMeso() >= 100000L) {
/* 732 */       Equip lazuliequip = ItemPotentialAndMagnify((Equip)chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short)-10), chr, false);
/* 733 */       Equip lapisequip = ((Equip)chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short)-11)).copyPotential(lazuliequip);
/* 734 */       chr.forceUpdateItem((Item)lazuliequip, true);
/* 735 */       chr.forceUpdateItem((Item)lapisequip, true);
/* 736 */       chr.equipChanged();
/* 737 */       chr.gainWeaponPoint(-600);
/* 738 */       chr.gainMeso(-100000L, false);
/* 739 */       chr.dropSpouseMessage(12, "潜能被变更了。");
     } else {
/* 741 */       chr.dropMessage(-1, "金币或WP不足，无法更改潜能。");
/* 742 */       c.sendEnableActions();
     }
   }

   public static Equip ItemPotentialAndMagnify(Equip toScroll, MapleCharacter player, boolean rand) { int potentialID;
/* 747 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 748 */     int reqLevel = ii.getReqLevel(toScroll.getItemId()) / 10;
/* 749 */     int stateLevel = (reqLevel >= 20) ? 19 : reqLevel;

/* 751 */     if (rand)
     {
/* 753 */       toScroll.randNewState(CubeConfig.INSTANCE.getChance(0, toScroll.getState(false) - 16), ItemConstants.PotentialConstants.getDefaultPotentialFlag(10000), 0);
     }
/* 755 */     boolean add = (toScroll.getState(false) >= 17 || toScroll.getState(false) <= 0);
/* 756 */     int pos = 0;
/* 757 */     int oldPotentialID = Math.abs(toScroll.getPotential(1, add)) % 1000000;

/* 759 */     if (oldPotentialID >= 100000) {
/* 760 */       pos = oldPotentialID / 100000;
/* 761 */       potentialID = oldPotentialID % 100000;
     } else {
/* 763 */       potentialID = 0;
     }
/* 765 */     int maxPos = (toScroll.getPotential(2, add) != 0) ? 3 : 2;
/* 766 */     int oldState = toScroll.getState(add) + 16;
/* 767 */     if (oldState > 20 || oldState < 17) {
/* 768 */       oldState = 17;
     }
/* 770 */     List<List<StructItemOption>> list = ii.getFilterPotentials();

/* 772 */     int abs = Math.abs(toScroll.getPotential(3, add));
/* 773 */     toScroll.setPotential(0, 3, add);
/* 774 */     boolean check = ItemConstants.PotentialConstants.PotentialFlag.前两条相同.check(abs);
/* 775 */     for (int i = 1; i <= maxPos; i++) {
/* 776 */       if (i == pos) {
/* 777 */         toScroll.setPotential(potentialID, pos, add);
       } else {
         StructItemOption itemOption;
         do {
/* 781 */           itemOption = ((List<StructItemOption>)list.get(Randomizer.nextInt(list.size()))).get(stateLevel);
/* 782 */         } while (itemOption == null || itemOption.reqLevel / 10 > stateLevel || 

/* 784 */           !GameConstants.optionTypeFits(itemOption.optionType, toScroll.getItemId()) || 
/* 785 */           !GameConstants.isBlockedPotential(toScroll, itemOption.opID, add, ItemConstants.PotentialConstants.PotentialFlag.点券光环.check(abs)) || 
/* 786 */           !GameConstants.potentialIDFits(itemOption.opID, oldState, ItemConstants.PotentialConstants.PotentialFlag.对等.check(abs) ? 1 : i) || (ItemConstants.PotentialConstants.PotentialFlag.去掉无用潜能
/* 787 */           .check(abs) && (!ItemConstants.PotentialConstants.PotentialFlag.去掉无用潜能.check(abs) || 
/* 788 */           ItemConstants.PotentialConstants.checkProperties(itemOption))));
/* 789 */         if (i == 1 && check) {
/* 790 */           toScroll.setPotential(itemOption.opID, 2, add);
         }
/* 792 */         if (i != 2 || !check) {
/* 793 */           toScroll.setPotential(itemOption.opID, i, add);
         }
       }
     }
/* 797 */     toScroll.initAllState();
/* 798 */     if (!add && toScroll.getState(false) >= 18 && toScroll.getStateMsg() < 3) {
/* 799 */       if (toScroll.getState(false) == 18 && toScroll.getStateMsg() == 0) {
/* 800 */         toScroll.setStateMsg(1);
/* 801 */         player.finishAchievement(52);
/* 802 */         if (!player.isAdmin()) {
/* 803 */           WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.itemMegaphone(player.getMedalText() + player.getName() + " : 鉴定出 A 级装备，大家祝贺他(她)吧！", true, player.getClient().getChannel(), (Item)toScroll));
         }
/* 805 */       } else if (toScroll.getState(false) == 19 && toScroll.getStateMsg() <= 1) {
/* 806 */         toScroll.setStateMsg(2);
/* 807 */         player.finishAchievement(53);
/* 808 */         if (!player.isAdmin()) {
/* 809 */           WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.itemMegaphone(player.getMedalText() + player.getName() + " : 鉴定出 S 级装备，大家祝贺他(她)吧！", true, player.getClient().getChannel(), (Item)toScroll));
         }
/* 811 */       } else if (toScroll.getState(false) == 20 && toScroll.getStateMsg() <= 2) {
/* 812 */         toScroll.setStateMsg(3);
/* 813 */         player.finishAchievement(54);
/* 814 */         if (!player.isAdmin()) {
/* 815 */           WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.itemMegaphone(player.getMedalText() + player.getName() + " : 鉴定出 SS 级装备，大家祝贺他(她)吧！", true, player.getClient().getChannel(), (Item)toScroll));
         }
       }
     }
/* 819 */     return toScroll; } public static void UserArcaneForceRequest(LittleEndianAccessor lea, MapleClient c, MapleCharacter player) { int slot; Equip equip;
     Equip equip1;
     Item item;
     short n;
/* 823 */     if (player == null || player.getMap() == null) {
       return;
     }
     int int1;
/* 827 */     switch (int1 = lea.readInt()) {
       case 0:
/* 829 */         slot = lea.readInt();
/* 830 */         lea.readInt();
/* 831 */         equip1 = null;
/* 832 */         item = player.getInventory(MapleInventoryType.EQUIP).getItem((short)slot);
/* 833 */         for (n = -1603; n <= -1600; n = (short)(n + 1)) {
/* 834 */           Equip equip2 = (Equip)player.getInventory(MapleInventoryType.EQUIPPED).getItem(n);
/* 835 */           if (equip2 != null && equip2.getARCLevel() < 15 && equip2.getARCExp() < ItemConstants.getArcUplevelNeedExp(equip2.getARCLevel(), equip2.getItemId() % 10) && ItemConstants.isArcaneForce(equip2.getItemId()) && item.getItemId() == equip2.getItemId()) {
/* 836 */             equip1 = equip2;
           }
         }
/* 839 */         if (item != null && ItemConstants.isArcaneForce(item.getItemId()) && equip1 != null && ItemConstants.isArcaneForce(equip1.getItemId()) && item.getItemId() == equip1.getItemId()) {
/* 840 */           int n2 = equip1.getItemId() % 10;
/* 841 */           Equip f3 = (Equip)item;
/* 842 */           int n3 = 0;
/* 843 */           short arcLevel = f3.getARCLevel();
/* 844 */           int arcExp = f3.getARCExp(); short n4;
/* 845 */           for (n4 = 1; n4 <= arcLevel; n4 = (short)(n4 + 1)) {
/* 846 */             n3 += ItemConstants.getArcUplevelNeedExp(n4, n2) / 3;
           }
/* 848 */           int n5 = n3 + arcExp;
/* 849 */           short arcLevel2 = equip1.getARCLevel();
/* 850 */           int arcExp2 = equip1.getARCExp();
/* 851 */           int needExp = ItemConstants.getArcUplevelNeedExp(arcLevel2, n2);
/* 852 */           if (arcExp2 < needExp) {
/* 853 */             equip1.setARCExp(Math.min(n5 + arcExp2, needExp));
/* 854 */             MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short)slot, (short)1, false, false);
/* 855 */             MapleInventoryManipulator.addItemList(c, Collections.singletonList(equip1), false);
           }
         }
         return;


       case 1:
/* 862 */         if ((equip = (Equip)player.getInventory(MapleInventoryType.EQUIPPED).getItem((short)-lea.readInt())) != null) {


/* 865 */           short n10, n12, n14, n15, n11, n13, n16, arcLevel3 = equip.getARCLevel();
/* 866 */           int n6 = equip.getItemId() % 10;
/* 867 */           int needExp = ItemConstants.getArcUplevelNeedExp(arcLevel3, n6);
/* 868 */           long needMeso = ItemConstants.getArcUplevelNeedMeso(arcLevel3, n6);
/* 869 */           if (player.getMeso() < needMeso) {
/* 870 */             player.dropMessage("你没有那么多金币！");

             return;
           }
/* 874 */           short n7 = (short)(arcLevel3 + 1);
/* 875 */           int n8 = equip.getARC() + n7 * (n6 + 3);
/* 876 */           equip.setARCExp(1);
/* 877 */           equip.setARCLevel((short)Math.min(n7, 15));
/* 878 */           equip.setARC((short)n8);
/* 879 */           int bs = JobConstants.getJobBranch(player.getJob());
/* 880 */           int n9 = n6 * 5 + 10;
/* 881 */           switch (bs) {
             case 1:
             case 5:
/* 884 */               n10 = (short)(equip.getStr() + n9);
/* 885 */               n11 = (short)(equip.getDex() + n9);
/* 886 */               equip.setStr(n10);
/* 887 */               equip.setDex(n11);
               break;

             case 2:
/* 891 */               n12 = (short)(equip.getInt() + n9);
/* 892 */               n13 = (short)(equip.getLuk() + n9);
/* 893 */               equip.setInt(n12);
/* 894 */               equip.setLuk(n13);
               break;

             case 3:
/* 898 */               n14 = (short)(equip.getStr() + n9);
/* 899 */               equip.setDex((short)(equip.getDex() + n9));
/* 900 */               equip.setStr(n14);
               break;

             case 4:
/* 904 */               n15 = (short)(equip.getDex() + n9);
/* 905 */               n16 = (short)(equip.getLuk() + n9);
/* 906 */               equip.setDex(n15);
/* 907 */               equip.setLuk(n16);
               break;
           }

/* 911 */           player.gainMeso(-needMeso, false);
/* 912 */           MapleInventoryManipulator.addItemList(c, Collections.singletonList(equip), false);
/* 913 */           player.dropMessage("神秘徽章已经强化成功！");
         }
         return;
     }

/* 918 */     if (player.isShowPacket())
/* 919 */       player.dropMessage(1, "[神秘徽章] 未知的操作码:" + int1);  }

 }


/* Location:              C:\PGX\Server.jar!\handling\channel\handler\ItemScrollHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */